package com.cneport.transfer.monitor.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cneport.transfer.monitor.entity.TransportLog;
import com.cneport.transfer.monitor.entity.TransportMsg;
import com.cneport.transfer.monitor.mapper.MonitoringViewMapper;
import com.cneport.transfer.util.XmlSerializer;



@Service
public class MonitoringViewService {
	
	@Autowired
	 private MonitoringViewMapper monitoringviewmapper;
	
	public List<TransportLog> queryMonitoringList(Map param){
		return monitoringviewmapper.queryMonitoringList(param);
	}
	
	public int countMonitoring(Map param){
		return monitoringviewmapper.countMonitoring(param);
	}
	
	public String getLogInfo(Map param) throws Exception{
			TransportMsg transportmsg = new TransportMsg();
			transportmsg = monitoringviewmapper.getLogInfo(param);
			String log = "";
			if(transportmsg != null && !"".equals(transportmsg)){
			log = new String(transportmsg.getMessgagecontent(),transportmsg.getMessgageencoding());
			log = XmlSerializer.formatXML(log);
			} 
			
		return log;
	}
	
	public void insertLogInfo(TransportLog transportlog){
		monitoringviewmapper.insertTransportLog(transportlog);
	}
	
	public void insertLogMsg(TransportMsg msg){
		monitoringviewmapper.insertLogMsg(msg);
	}

}
